/*
 * @Description: Animal
 * @Author: rendc
 * @Date: 2024-09-13 10:30:11
 * @LastEditors: rendc
 * @LastEditTime: 2024-09-13 15:42:01
 */
public class Animal {
  // 成员变量
  // 私有
  private String name; // 名字
  // 公开变量 显示初始化
  public int number = 10; // 数量
  // get set

  public Animal() {
    System.out.println("Animal的无参构造器");
  };

  public Animal(String name) {
    this(name, 0);// 放到第1行有效代码的位置
    System.out.println("Animal的单参构造器");
  }

  public Animal(String name, int number) {
    System.out.println("Animal的全参构造器");
    this.name = name;
    this.number = number;
  };

  public void setName(String name) {
    this.name = name;
  }

  public String getName() {
    return this.name;
  }

  public void setNumber(int number) {
    this.number = number;
  }

  public int getNumber() {
    return this.number;
  }

  // sayHello
  public void sayHello() {
    System.out.println("自有:name:" + name);
    System.out.println("自有:number: " + number);
  }
}